import { BasicColumn, FormSchema } from '@/components/Table';
import { h, ref } from 'vue';
import { Tag, DatePicker } from 'ant-design-vue';

type CheckedType = boolean | string | number;
export const columns: BasicColumn[] = [
  {
    title: '姓名',
    dataIndex: 'userName',
  },

  {
    title: '是否月满勤',
    dataIndex: 'isFullMonth',
    width: 80,
    customRender: ({ record }) => {
      const isRead = record.isFullMonth;
      const enable = ~~isRead === 1;
      const color = enable ? 'green' : 'red';
      const text = enable ? '是' : '否';
      return h(Tag, { color: color }, () => text);
    },
  },
  {
    title: '是否月全勤',
    dataIndex: 'isAllMonth',
    width: 80,
    customRender: ({ record }) => {
      const isRead = record.isAllMonth;
      const enable = ~~isRead === 1;
      const color = enable ? 'green' : 'red';
      const text = enable ? '是' : '否';
      return h(Tag, { color: color }, () => text);
    },
  },
  {
    title: '是否年满勤',
    dataIndex: 'isFullYear',
    width: 80,
    customRender: ({ record }) => {
      const isRead = record.isFullYear;
      const enable = ~~isRead === 1;
      const color = enable ? 'green' : 'red';
      const text = enable ? '是' : '否';
      return h(Tag, { color: color }, () => text);
    },
  },
  {
    title: '是否年全勤',
    dataIndex: 'isAllYear',
    width: 80,
    customRender: ({ record }) => {
      const isRead = record.isAllYear;
      const enable = ~~isRead === 1;
      const color = enable ? 'green' : 'red';
      const text = enable ? '是' : '否';
      return h(Tag, { color: color }, () => text);
    },
  },

  {
    title: '归属日期',
    dataIndex: 'day',
    width: 100,
  },
  {
    title: '月份',
    dataIndex: 'month',
    width: 100,
  },
  {
    title: '系统信息',
    dataIndex: 'note',
    width: 80,
  },
  {
    title: '打卡时间',
    dataIndex: 'createTime',
    width: 180,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'keyword',
    label: '姓名',
    component: 'Input',
    colProps: { span: 8 },
  },
  // {
  //   field: 'month',
  //   label: '月份',
  //   component: 'DatePicker',
  //   componentProps: {
  //     // YYYY-MM
  //     valueFormat:"YYYY-MM",
  //     format:"YYYY-MM"
  //   },
  //   colProps: { span: 8 },
  // },
];

export const formSchema: FormSchema[] = [
  {
    field: 'userName',
    label: '成员名称',
    required: true,
    component: 'Input',
  },
  {
    field: 'isRead',
    label: '是否参与读书',
    component: 'Select',
    componentProps: {
      options: [
        { label: '否', value: 0 },
        { label: '是', value: 1 },
      ],
    },
  },
];

export const addIntegralformSchema: FormSchema[] = [
  {
    label: '姓名',
    field: 'userName',
    // component: 'Ainput',
    slot: 'Ainput',
    required: true,
  },
  {
    field: 'date',
    label: '所属日期',
    component: 'DatePicker',
    required: true,
  },
  {
    label: 'userId',
    field: 'userId',
    show: false,
  },
  {
    label: '积分',
    field: 'integral',
    component: 'InputNumber',
    required: true,
  },
  {
    field: 'sysNote',
    label: '打卡类型',
    required: true,
    component: 'Select',
    componentProps: {
      options: [
        { label: '日常打卡', value: '日常打卡' },
        { label: '补卡', value: '补卡' },
        { label: '提前读书', value: '提前读书' },
      ],
    },
    colProps: { span: 8 },
  },
];
